package com.nekonomics
package api.dto.response

import domain.detail.OrderSummary

import zio.json.JsonEncoder

import java.time.LocalDate

case class OrderSummaryDto(
  date: LocalDate,
  totalOrders: Int
) derives JsonEncoder


object  OrderSummaryDto {
  given Ordering[OrderSummaryDto] = Ordering.by((_: OrderSummaryDto).date)



  def of(summary: OrderSummary): OrderSummaryDto =  OrderSummaryDto(
    date = summary.dateKey,
    totalOrders = summary.paidOrders + summary.unpaidOrders
  )
}
